package pl.cvplus.entity;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_user", schema = "public", catalog = "")
@Entity
public class CpUser {
    private Integer passwordFk;

    @javax.persistence.Column(name = "password_fk", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getPasswordFk() {
        return passwordFk;
    }

    public void setPasswordFk(Integer passwordFk) {
        this.passwordFk = passwordFk;
    }

    private String userLogin;

    @javax.persistence.Column(name = "user_login", nullable = false, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getUserLogin() {
        return userLogin;
    }

    public void setUserLogin(String userLogin) {
        this.userLogin = userLogin;
    }

    private Date modificationDate;

    @javax.persistence.Column(name = "modification_date", nullable = true, insertable = true, updatable = true, length = 13, precision = 0)
    @Basic
    public Date getModificationDate() {
        return modificationDate;
    }

    public void setModificationDate(Date modificationDate) {
        this.modificationDate = modificationDate;
    }

    private String modifier;

    @javax.persistence.Column(name = "modifier", nullable = true, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getModifier() {
        return modifier;
    }

    public void setModifier(String modifier) {
        this.modifier = modifier;
    }

    private String userType;

    @javax.persistence.Column(name = "user_type", nullable = false, insertable = true, updatable = true, length = 1, precision = 0)
    @Basic
    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    private Integer companyData;

    @javax.persistence.Column(name = "company_data", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getCompanyData() {
        return companyData;
    }

    public void setCompanyData(Integer companyData) {
        this.companyData = companyData;
    }

    private Integer personalData;

    @javax.persistence.Column(name = "personal_data", nullable = true, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getPersonalData() {
        return personalData;
    }

    public void setPersonalData(Integer personalData) {
        this.personalData = personalData;
    }

    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpUser cpUser = (CpUser) o;

        if (companyData != null ? !companyData.equals(cpUser.companyData) : cpUser.companyData != null) return false;
        if (id != null ? !id.equals(cpUser.id) : cpUser.id != null) return false;
        if (modificationDate != null ? !modificationDate.equals(cpUser.modificationDate) : cpUser.modificationDate != null)
            return false;
        if (modifier != null ? !modifier.equals(cpUser.modifier) : cpUser.modifier != null) return false;
        if (passwordFk != null ? !passwordFk.equals(cpUser.passwordFk) : cpUser.passwordFk != null) return false;
        if (personalData != null ? !personalData.equals(cpUser.personalData) : cpUser.personalData != null)
            return false;
        if (userLogin != null ? !userLogin.equals(cpUser.userLogin) : cpUser.userLogin != null) return false;
        if (userType != null ? !userType.equals(cpUser.userType) : cpUser.userType != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = passwordFk != null ? passwordFk.hashCode() : 0;
        result = 31 * result + (userLogin != null ? userLogin.hashCode() : 0);
        result = 31 * result + (modificationDate != null ? modificationDate.hashCode() : 0);
        result = 31 * result + (modifier != null ? modifier.hashCode() : 0);
        result = 31 * result + (userType != null ? userType.hashCode() : 0);
        result = 31 * result + (companyData != null ? companyData.hashCode() : 0);
        result = 31 * result + (personalData != null ? personalData.hashCode() : 0);
        result = 31 * result + (id != null ? id.hashCode() : 0);
        return result;
    }

    private Collection<CpCv> cpCvsById;

    @OneToMany(mappedBy = "cpUserByUserFk")
    public Collection<CpCv> getCpCvsById() {
        return cpCvsById;
    }

    public void setCpCvsById(Collection<CpCv> cpCvsById) {
        this.cpCvsById = cpCvsById;
    }

    private Collection<CpPassword> cpPasswordsById;

    @OneToMany(mappedBy = "cpUserByUserFk")
    public Collection<CpPassword> getCpPasswordsById() {
        return cpPasswordsById;
    }

    public void setCpPasswordsById(Collection<CpPassword> cpPasswordsById) {
        this.cpPasswordsById = cpPasswordsById;
    }

    private CpPassword cpPasswordByPasswordFk;

    @ManyToOne
    public
    @JoinColumn(name = "password_fk", referencedColumnName = "id", nullable = false)
    CpPassword getCpPasswordByPasswordFk() {
        return cpPasswordByPasswordFk;
    }

    public void setCpPasswordByPasswordFk(CpPassword cpPasswordByPasswordFk) {
        this.cpPasswordByPasswordFk = cpPasswordByPasswordFk;
    }

    private Collection<CpUserRoles> cpUserRolesesById;

    @OneToMany(mappedBy = "cpUserByUserFk")
    public Collection<CpUserRoles> getCpUserRolesesById() {
        return cpUserRolesesById;
    }

    public void setCpUserRolesesById(Collection<CpUserRoles> cpUserRolesesById) {
        this.cpUserRolesesById = cpUserRolesesById;
    }
}
